﻿
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;


namespace TEL.TelPhoneF
{
    [RunInstaller(true)]
    public class InstallAction : Installer
    {
        public InstallAction()
            : base()
        {
          
        }
        
        protected override void OnBeforeInstall(IDictionary savedState)
        {
            MessageBox.Show("BeforeInstall ");
            try
            {
                System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName("TelPhoneF");
                if (process.Length == 0)
                {

                }
                else
                {
                    foreach (var item in process)
                    {
                        item.Kill();
                        MessageBox.Show("KILL TelPhoneF");
                    }
                }
            }
            catch (Exception)
            {
            }
        }

        public override void Commit(IDictionary savedState)
        {
            Process p = new Process();
            InstallContext cont = this.Context;

            ProcessStartInfo inf = new ProcessStartInfo(cont.Parameters["assemblypath"]);
            p.StartInfo = inf;
            p.Start();
        }
        
    }


   
}